

<template tag="以下文档内容为hycli自动生成">
  <el-dialog
    v-model="conf.visible"
    v-if="conf.visible" 
    :title="title"
    :width="conf.width"
    draggable
    align-center="true"
    :close-on-click-modal="false"
  >
<el-form :model="form"  ref="form" :rules="rules_aaazk">
    <el-row>
    <el-col :span="12">
    <!-- {"index":25,"raw":"msg_type","name":"msg_type","cname":"MsgType","type":{"raw":"number(2)","name":"number","len":2,"dlen":0},"defValue":"0","allowNull":true,"constraints":["l","le","v","c","u","sl(msg_type)","color"],"desc":{"raw":"消息类型:0-系统消息;1-用户消息","name":"消息类型"}} -->
     <!--消息类型 下拉控件 -->
    <el-form-item prop="msg_type" label="消息类型" label-width="100px" label-position="right">
      <el-select   v-model="form.msg_type" style="width: 100%" filterable clearable
        placeholder="请选择消息类型:0-系统消息;1-用户消息" >
        <el-option v-for="item in msg_typeList" :key="item.value" :label="item.name" :value="item.value" />
      </el-select>
      <el-tooltip raw-content="true" content="消息类型:0-系统消息;1-用户消息" placement="bottom" effect="light">
        <i class="form_item_info fa fa-info-circle"  aria-hidden="true" />
      </el-tooltip>
    </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":26,"raw":"title","name":"title","cname":"Title","type":{"raw":"varchar(64)","name":"varchar","len":64,"dlen":0},"defValue":"","allowNull":false,"constraints":["q","l","le","v","c","u","DN","rows(1)"],"desc":{"raw":"消息标题","name":"消息标题"}} -->
    <!--消息标题 输入控件 -->
    <el-form-item prop="title" label="消息标题" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.title"  maxlength="64" 
      :rows="1"  type="textarea" show-word-limit  placeholder="请输入消息标题"  />
      </el-form-item>
    </el-col>
    <el-col :span="24">
    <!-- {"index":27,"raw":"content","name":"content","cname":"Content","type":{"raw":"text","name":"text","len":0,"dlen":0},"defValue":"","allowNull":false,"constraints":["le","v","c","u","rows(8)"],"desc":{"raw":"消息内容","name":"消息内容"}} -->
    <!--消息内容 输入控件 -->
    <el-form-item prop="content" label="消息内容" label-width="100px" label-position="right">
      <el-input clearable style="width: 100%" v-model="form.content" 
      :rows="8"  type="textarea" show-word-limit  placeholder="请输入消息内容"  />
      </el-form-item>
    </el-col>
    </el-row>
</el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="hide" icon="close">取消</el-button>
        <el-button type="primary" @click="save" icon="select">提交</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script>
import rtext from "@/views/cmpnts/rtext.vue"
export default {
  components: {
    rtext
},
  data() {
    return {
      conf: {
        visible: false,
        width:"60%",
        uploadPath:this.$theia.env.join("/file/upload"),
      },
      title:"修改通知消息",
rules_aaazk:{
    msg_type:[{required:false,message:"请输入消息类型",trigger: 'blur'}],
    title:[{required:true,message:"请输入消息标题",trigger: 'blur'}],
    content:[{required:true,message:"请输入消息内容",trigger: 'blur'}],
  },
    form:{
        msg_type:"",
        title:"",
        content:"",
    },
    msg_typeList:[],
    }
  },
  methods: {
    show(form) {
      this.conf.visible = true;
      this.loadEnums_aaazk()
      this.form = Object.assign(form,this.$route.params)
      this.get(form)
    },
      get(form){
        let that = this
        this.conf.loading = true
        let postForm = {}
        postForm.mn_id = form.mn_id
        this.$theia.http.get("/ws/message/notification",postForm).then(res=>{
          that.form = Object.assign(that.form, res)
        //处理枚举重新绑定
          this.loadEnums_aaazk()
          that.conf.loading = false
        }).catch(res=>{
          let code = ((res||{}).response||{}).status||0
          let msg = `通知消息查询失败(${code})`
          that.$notify.error({title: '失败',message:msg ,duration:5000})
        })
    },
    save(){
        this.$refs.form.validate((v=>{
            if(v) this.onSave()
        }))
    },
    onSave(){
      let that = this
        let postForm = Object.assign({},this.form)
        this.$theia.http.put("/ws/message/notification",postForm).then(res=>{
            that.$notify.success({title: '成功',message: '通知消息保存成功',duration:5000})
            that.$theia.enum.clear("message_notification")
            that.$theia.enum.get("message_notification")
            that.hide()
            that.$emit("onsaved")
        }).catch(res=>{
            let code = ((res||{}).response||{}).status||0
            let msg = `通知消息修改失败(${code})`
            that.$notify.error({title: '失败',message: msg,duration:5000})
        })
    },
    hide() {
      this.conf.visible = false;
      this.$refs.form.resetFields();
    },
     onUploadSuccess(response){
    },
    loadEnums_aaazk(){
        //消息类型
        this.msg_typeList = this.$theia.enum.get("msg_type","","" ,false,"")
    },

  },
};
</script>

<style scoped>
.form_item_info{
  margin-left: 4px;
  color:#999;
}
.form_item_info:hover{
  cursor: pointer;
  font-weight: 500;
  color:#333;
}
</style>